package com.wanghlme.leetcodecn;

import java.util.HashSet;
import java.util.Set;

/**
 * <p>剑指 Offer 03. 数组中重复的数字</p>
 *
 * @author wanghlme
 * @version 1.0
 */
public class LC_JZ03 {
    public static void main(String[] args) {
        System.out.println(new Solution().findRepeatNumber(new int[]{2, 3, 1, 0, 2, 5, 3}));
    }

    static class Solution {
        public int findRepeatNumber(int[] nums) {
            Set<Integer> set = new HashSet<Integer>();
            int repeat = -1;
            for (int num : nums) {
                if (!set.add(num)) {
                    repeat = num;
                    break;
                }
            }
            return repeat;
        }
    }
}
